﻿using System;

namespace Tuxedo.Compile
{
	internal class StringConstant : Constant
	{
		public string Value { get; private set; }
		public override object ObjectValue { get { return this.Value; } }

		public StringConstant(string value)
		{
			this.Value = value;
		}

		public override Expression Add(Constant other)
		{
			string otherValue = null;
			if (other is IntegerConstant) otherValue = ((IntegerConstant)other).Value.ToString();
			else if (other is LongConstant) otherValue = ((LongConstant)other).Value.ToString();
			else if (other is FloatConstant) otherValue = ((FloatConstant)other).Value.ToString();
			else if (other is DoubleConstant) otherValue = ((DoubleConstant)other).Value.ToString();
			else if (other is BooleanConstant) otherValue = ((BooleanConstant)other).Value.ToString();
			else if (other is StringConstant) otherValue = ((StringConstant)other).Value.ToString();
			else if (other is CharConstant) otherValue = ((CharConstant)other).Value.ToString();

			if (otherValue == null)
			{
				throw new NotImplementedException();
			}

			return new StringConstant(this.Value + otherValue);
		}
	}
}
